#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    :  
# @function: 
# @version :

from pymongo import MongoClient

# 连接MongoDB数据库
client = MongoClient(host='127.0.0.1', port=27017)
collection = client['spiders10']['stu']
# 插入单条数据
student = {'id': '20170101', 'name': 'Jordan', 'age': 20, 'gender': 'male'}
result = collection.insert_one(student)
print(result)

# 插入多条数据
student1 = {'id': '20170101', 'name': 'Jordan', 'age': 20, 'gender': 'male'}
student2 = {'id': '20170202', 'name': 'Mike', 'age': 21, 'gender': 'male'}
collection.insert_many([student1, student2])
